﻿using System;
using System.Data;
using System.Text;
using System.Web;
using AnyOffice.Components;
using AnyOffice.DAL;
namespace AnyOffice.general.system.workflow.flow_form
{  
    public partial class form_export : ModulePage
    {       

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                int num = (Request.QueryString["form_id"] == null) ? 0 : int.Parse(Request.QueryString["form_id"].ToString());
                DataTable table = new FlowFormTypeDao().SelectByFormId(base.Conn, num);
                if (table.Rows.Count > 0)
                {
                    string str = table.Rows[0]["FormName"].ToString();
                    string str2 = ".html";
                    while (HttpUtility.UrlEncode(str + str2, Encoding.UTF8).Length > 156)
                    {
                        str = str.Substring(0, str.Length - 1);
                    }
                    str = HttpUtility.UrlEncode(str + str2, Encoding.UTF8);
                    string s = (table.Rows[0]["FormModel"] != DBNull.Value) ? table.Rows[0]["FormModel"].ToString() : "";
                    Response.ContentType = "application/octet-stream";
                    Response.AddHeader("Content-Disposition", "attachment;filename=" + str);
                    Response.Clear();
                    Response.Buffer = true;
                    Response.BinaryWrite(Encoding.Default.GetBytes(s));
                    Response.End();
                }
            }
        }
       
    }
}

